home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * IS.js
- *
- * USAGE
- * Part of IS JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 1999-2000 Innovative Systems SRL.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Innovative Systems SRL
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Innovative Systems SRL.
- *
- * <copyright@innovative.ro>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- /****h* IS_JavaScript_Library/IS
- *
- * NAME
- * IS JavaScript Library / main module.
- *
- * DESCRIPTION
- * Definition of IS "namespace".
- *
- * NOTES
- * (*) To place another name under this namespace use:
- * IS.prototype.<your-name> = <whatever>;
- *
- * (*) This file also contains an instance of the ISLib object.
- *
- ****/
-
- function IS_getLibHandle()
- {
- return ((typeof(top) != "undefined" && typeof(top._is) != "undefined") ? top._is : // browsers
- ((typeof(top) != "undefined" && typeof(top.opener) != "undefined" && top.opener != null && typeof(top.opener._is) != "undefined") ? top.opener._is : // browsers
- ((typeof(MM) != "undefined" && typeof(MM._is) != "undefined") ? MM._is : // MacroMedia DW
- ((typeof(_is) != "undefined") ? _is : null)))); // ??
- }
-
- var IS = IS_getLibHandle();
- if ( IS == null )
- {
- /****m* ISJS/instanceOf
- *
- * NAME
- * instanceOf( object, constructor )
- *
- * USAGE
- * object -- object instance
- * constructor -- class constructor
- *
- * DESCRIPTION
- * Tests if an object instance is of a specified class.
- *
- * RETURN VALUE
- * true -- if 'object' is an instance of type 'constructor'
- * false -- in any other case
- *
- ****/
- function IS_instanceOf (object, constructor)
- {
- while (object != null)
- {
- if (object == constructor.prototype)
- {
- return true;
- }
- object = object.__proto__;
- }
-
- return false;
- }
-
-
- /****m* ISJS/addVariable
- *
- * NAME
- * addVariable( name, initValue )
- *
- * USAGE
- * name -- variable name
- * initValue -- initial value
- *
- * DESCRIPTION
- * Adds a new variable, 'name', to ISJSLib namespace. If 'initValue' is specified
- * the new variable will be initialized with this value.
- *
- * RETURN VALUE
- * none
- *
- ****/
- function IS_addVariable( name, initValue )
- {
- if ( arguments.length == 0 ) { return; }
- if ( arguments.length == 1 ) { initValue = null; }
-
- eval( "IS." + name + " = initValue" );
- }
-
-
- /****m* ISJS/delVariable
- *
- * NAME
- * delVariable( name )
- *
- * USAGE
- * name -- variable name
- *
- * DESCRIPTION
- * Removes a variable, 'name', from ISJSLib namespace
- *
- * RETURN VALUE
- * none
- *
- ****/
- function IS_delVariable( name )
- {
- if ( arguments.length == 0 ) { return; }
-
- if ( typeof( eval( "IS." + name ) ) != "undefined" ) {
- eval( "delete IS." + name );
- }
- }
-
-
- /****m* IS/setLibPath
- *
- * NAME
- * setLibPath( path )
- *
- * USAGE
- * path: the ISJS library path
- *
- * DESCRIPTION
- * Sets the path of the ISJS library. The path will be used as a default for
- * all module loading operations.
- *
- * RETURN VALUE
- * none
- *
- * SEE ALSO
- * IS/getLibPath
- * IS/loadModule
- ****/
-
- function IS_setLibPath (path)
- {
- IS_addVariable ("LIB_PATH", path);
- }
-
- /****m* IS/getLibPath
- *
- * NAME
- * getLibPath()
- *
- * RETURN VALUE
- * libPath: the ISJS library path
- *
- * DESCRIPTION
- * Gets the path of the ISJS library
- *
- * SEE ALSO
- * IS/setLibPath
- * IS/loadModule
- ****/
-
- function IS_getLibPath (path)
- {
- return (IS.LIB_PATH != null ? IS.LIB_PATH : ".");
- }
-
- /****m* IS/loadModule
- *
- * NAME
- * loadModule( moduleList [, modulePath] )
- *
- * USAGE
- * includeList: list of include files
- *
- * RETURN VALUE
- * none
- *
- * DESCRIPTION
- * Includes all files specified in the 'includeList' into the current document.
- * Note that the files are included at the current document position, meaning
- * that the call can not be used to include a JS source file into another JS
- * source file, as the including file is already loaded.
- *
- * SEE ALSO
- * IS/getLibPath
- * IS/setLibPath
- ****/
-
- function IS_loadModule (module, loadPath)
- {
- if (module != null)
- {
- if (loadPath == null) {
- loadPath = IS_getLibPath ();
- }
-
- if (typeof (module) != "string" && module.length != null)
- {
- for (var i = 0; i < module.length; i++)
- {
-
- document.writeln (
- //alert (
- '<script language="JavaScript1.2" src="' +
- loadPath + '/' + module[i] + '">' + '</' + 'script>');
- }
- }
- else
- {
- document.writeln (
- //alert (
- '<script language="JavaScript1.2" src="' +
- loadPath + '/' + module.toString () + '">' + '</' + 'script>');
- }
- }
- }
-
- function IS_isModuleInitialized (moduleName)
- {
- var modulesList = moduleName.split(".");
- var o;
- var m = "";
- for (var i=0;i<modulesList.length-1;i++) {
- m += modulesList[i];
- o = eval (m);
- if (typeof(o) == "undefined")
- return true;
- m += ".";
- }
- o = eval(moduleName);
- if (typeof(o) != "undefined")
- return true;
- return false;
- }
-
- /****m* ISJS/getFrameByName
- *
- * NAME
- * getFrameByName( name, root )
- *
- * USAGE
- * name -- frame name
- * root -- where to start looking for the frame
- *
- * DESCRIPTION
- * Searches for a frame named 'name' in the 'root' object and in any of its frames.
- *
- * RETURN VALUE
- * [object] -- frame object, if a frame is found
- * null -- in any other case
- *
- ****/
- function IS_getFrameByName( name, root )
- {
- if ( arguments.length < 2 ) {
- root = top;
- }
-
- if ( name == root.name ) {
- return root;
- }
-
- // NOTE: the conditional code below was written due to a strange behavior of
- // Microsoft's browsers. When a frame was loaded with an page stored outside of
- // the local site the frame object properties could not be accessed any more (an
- // 'Access is denied.' error will occur). Using this piece of code eliminates the
- // problem.
-
- // <CONDITIONAL CODE>
- // <Microsoft browsers>
- if ( /Microsoft/.test( navigator.appName ) )
- {
- if ( typeof( eval( "root." + name ) ) == "object" )
- return eval( "root." + name );
- }
- // <CONDITIONAL CODE>
-
- for ( var i = 0; i < root.frames.length; i++ )
- {
- var retFrame = this.getFrameByName( name, root.frames[ i ] );
-
- if ( null != retFrame ) {
- return retFrame;
- }
- }
-
- return null;
- }
-
-
- /****m* ISJS/getFrameByDocument
- *
- * NAME
- * getFrameByDocument( document, root )
- *
- * USAGE
- * document -- document name
- * root -- where to start looking for the frame
- *
- * DESCRIPTION
- * Searches for a frame which holds the 'document' object.
- *
- * RETURN VALUE
- * [object] -- frame object, if a frame is found
- * null -- in any other case
- *
- ****/
- function IS_getFrameByDocument( document, root )
- {
- if (typeof(IS.Document) != "undefined" && IS.instanceOf(document, IS.Document))
- {
- // 'document' is actually a IS document variable; make the appropriate call
- return ( typeof( root ) != "undefined" )
- ? this.getFrameByDocument( document.getDocument(), root )
- : this.getFrameByDocument( document.getDocument() );
- }
- else
- {
- if ( arguments.length < 2 ) {
- root = top;
- }
-
- if ( document == root.document ) {
- return root;
- }
-
- for ( var i = 0; i < root.frames.length; i++ )
- {
- var retFrame = this.getFrameByDocument( document, root.frames[ i ] );
-
- if ( null != retFrame ) {
- return retFrame;
- }
- }
-
- return null;
- }
- }
-
-
- /****c* ISJS/ISLib
- *
- * NAME
- * ISLib()
- *
- * USAGE
- *
- * DESCRIPTION
- * Space name for all ISJS related functionality.
- *
- * SEE ALSO
- *
- ****/
- function ISLib()
- {
- // __proto__ initialization
- this.__proto__ = ISLib.prototype;
-
- // type constant(s)
- // ...Innovative Systems JavaScript Library (_IS_)
- this.TYPE_NAMESPACE = "is_namespace";
-
- // properties
- this.type = this.TYPE_NAMESPACE;
- this.version = "1.91"; // library version; DON'T FORGET to update this value every time a change occure to the library
-
- // method(s)
- this.instanceOf = IS_instanceOf;
-
- this.addVariable = IS_addVariable;
- this.delVariable = IS_delVariable;
-
- this.setLibPath = IS_setLibPath;
- this.getLibPath = IS_getLibPath;
- this.loadModule = IS_loadModule;
-
- this.getFrameByName = IS_getFrameByName;
- this.getFrameByDocument = IS_getFrameByDocument;
-
- this.isModuleInitialized = IS_isModuleInitialized;
- }
-
-
- /****v* ISJS/is_
- *
- * NAME
- * is
- *
- * DESCRIPTION
- * Instance of ISLib (one per application).
- *
- * NOTES
- * If the library is used...
- * ...with Macromedia Dreamweaver: 'MM._is' object will be instantiated
- * ...with a Internet browser: 'top._is' object will be instantiated
- * ...in any other case: '_is' object will be instantiated.
- *
- ****/
- if ((typeof(MM) != "undefined") && (typeof(MM._is) == "undefined")) { MM._is = new ISLib(); }
- else if ((typeof(top) != "undefined") && (typeof(top.is) == "undefined")) { top._is = new ISLib(); }
- else { _is = new ISLib(); }
-
- }
- var IS = IS_getLibHandle();
-
-